package com.example.spring.service;

import com.example.spring.dao.ProductDao;

/**
 * 产品服务 - 没有接口的实现
 */
public class ProductService {
    private ProductDao productDao;

    public ProductService(ProductDao productDao) {
        this.productDao = productDao;
    }
    // 添加无参构造器
    public ProductService() {
    }
    // 添加getter方法
    public ProductDao getProductDao() {
        return productDao;
    }
    public void createProduct(String productName) {
        productDao.saveProduct(productName);
        System.out.println("创建产品业务逻辑: " + productName);
    }

    public void modifyProduct(String productName) {
        productDao.updateProduct(productName);
        System.out.println("修改产品业务逻辑: " + productName);
        // 模拟异常
        if ("error".equals(productName)) {
            throw new RuntimeException("修改产品异常");
        }
    }
}
